<?php

/**
 * Admin_Form_Vydavatel - Formulář pro přidání nebo úpravu vydavatele
 * @author Petr Fořt
 * @package Knihovna\Modules\Admin\Forms
 */

class Admin_Form_Vydavatel extends Zend_Form
{

    public function init()
    {
     /**
     * Inicializuje formulář
     *
     * @author Petr Fořt
     */
     $validatorint = new Zend_Validate_Int();


     $this->setName('vydavatel');

        $id = new Zend_Form_Element_Hidden('id_vydavatele');
        $id->addFilter('Int');

        $jmeno = new Zend_Form_Element_Text('jmeno');
        $jmeno->setLabel('Jméno')
              ->setRequired(true)
              ->addFilter('StripTags')
              ->addFilter('StringTrim')
              ->addValidator('NotEmpty')
              ->addValidator('StringLength', false, array(1, 80));


        $ico = new Zend_Form_Element_Text('ico');
        $ico->setLabel('IČO')
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->addValidator('StringLength', false, array(4, 8))
            ->addValidator('alnum')
            ->addValidator($validatorint)
            ->setRequired(true);

        $ulice = new Zend_Form_Element_Text('ulice');
        $ulice->setLabel('Ulice')
            ->setRequired(true)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->addValidator('StringLength', false, array(1, 80));

        $mesto = new Zend_Form_Element_Text('mesto');
        $mesto->setLabel('Město')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator('NotEmpty')
               ->addValidator('StringLength', false, array(1, 80));;

        $cp = new Zend_Form_Element_Text('cp');
        $cp->setLabel('Číslo popisné')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator('NotEmpty')
               ->addValidator('StringLength', false, array(1, 15));;

        $psc = new Zend_Form_Element_Text('psc');
        $psc->setLabel('PSČ')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator('NotEmpty')
               ->addValidator('StringLength', false, array(5, 5))
               ->addValidator($validatorint)
               ->addValidator('alnum');

        $telefon = new Zend_Form_Element_Text('telefon');
        $telefon->setLabel('Telefon')
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator($validatorint)
               ->addValidator('alnum');

        $fax = new Zend_Form_Element_Text('fax');
        $fax->setLabel('Fax')
               ->addFilter('StripTags')
               ->addFilter('StringTrim');

        $www = new Zend_Form_Element_Text('www');
        $www->setLabel('WWW stránky')
                ->addFilter('StripTags')
                ->addFilter('StringTrim');

        $odeslat = new Zend_Form_Element_Submit('submit');
        $odeslat->setLabel('Uložit');
        $odeslat->setAttrib('id_vydavatele', 'submitbutton');

        $this->addElements(array($id, $jmeno, $ico, $ulice, $mesto, $cp, $psc, $telefon, $fax, $www, $odeslat));

    }

}

